cmake_minimum_required(VERSION 4.1)

#configure_file(config.h.in config.h)
add_definitions(-Duid_t=long -DVERSION="2.3.12")
add_definitions(-DWINDOWS -D_MSVC_ -DWINSOCK -DHAVE_VARARGS_H -DUNIXODBC_SOURCE -DLTDL -DHAVE_STDARG_H -DSIZEOF_LONG_INT=8)
add_definitions(-DSHLIBEXT="dll" -DDEFLIB_PATH="." -Derror_t=int -DSYSTEM_FILE_PATH="." -DLIB_PREFIX="." -DINCLUDE_PREFIX="." -DBIN_PREFIX="." -DEXEC_PREFIX="." -DPREFIX=".")
remove_definitions(-DHAVE_ARGZ_H -DHAVE_WORKING_ARGZ -DHAVE_DLFCN_H -DHAVE_STRCASECMP -DHAVE_LIBDLLOADER -DHAVE_UNISTD_H -DHAVE_STRINGS_H)
include_directories(include libltdl libltdl/libltdl Drivers/nn)

aux_source_directory(libltdl libltdl)
add_library(libltdl STATIC ${libltdl} libltdl/loaders/preopen.c)

aux_source_directory(ini ini)
add_library(libinilc STATIC ${ini})

aux_source_directory(log log)
add_library(libloglc STATIC ${log})

aux_source_directory(lst lst)
add_library(liblstlc STATIC ${lst})

if(HAS_MYSQL)
aux_source_directory(Drivers/Minisql minisql)
add_library(minisql STATIC ${minisql})
endif()

aux_source_directory(Drivers/nn nn)
add_library(nn STATIC ${nn})

if(HAS_POSTGRE)
aux_source_directory(Drivers/postgre7.1 postgre)
add_library(postgre STATIC ${postgre})
endif()

aux_source_directory(Drivers/template template)
add_library(template STATIC ${template})

aux_source_directory(DriverManager DriverManager)
#ist(REMOVE_ITEM DriverManager DriverManager/__attribute.c DriverManager/__stats.c DriverManager/__info.c DriverManager/__handles.c DriverManager/__connection.c)
add_library(DriverManager STATIC ${DriverManager})

aux_source_directory(odbcinst odbcinst)
# aux_source_directory(log odbcinst)
# aux_source_directory(ini odbcinst)
# aux_source_directory(lst odbcinst)
# aux_source_directory(libltdl odbcinst)
# aux_source_directory(DriverManager odbcinst)
add_library(odbcinst STATIC ${odbcinst} extras/snprintf.c extras/strcasecmp.c)
# target_link_libraries(odbcinst liblstlc libloglc liblstlc libltdl libinilc nn)

set(odbc_sql exe/isql.c)
add_executable(odbc_sql ${odbc_sql})
target_link_libraries(odbc_sql odbcinst liblstlc libloglc liblstlc libltdl libinilc DriverManager)

set(odbc_test exe/odbcinst.c)
add_executable(odbc_test ${odbc_test})
target_link_libraries(odbc_test odbcinst liblstlc libloglc liblstlc libltdl libinilc template)
